package com.xbongbong.parent.interfaces;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.UserVO;
import com.xbongbong.pro.formexplain.pojo.dto.HandlerExplainDTO;
import com.xbongbong.pro.formexplain.pojo.vo.HandlerExplainVO;

import java.util.List;

/**
 * @author 吴峰
 * @date 2021/12/22 20:52
 */
public interface ParentBusinessDetailService<T, D> {




    /**
     * 业务类型
     * @return
     */
    List<Integer> businessType();

    /**
     * 获取数据
     * @param corpid
     * @param saasMark
     * @param businessType
     * @param subBusinessType 子业务类型
     * @param dataId
     * @param formId
     * @return 返回数据
     * @throws XbbException
     */
    D getData(Integer businessType, Integer subBusinessType, Integer saasMark, String corpid, Long dataId, Long formId) throws XbbException;


    /**
     * 校验权限，详情页权限判断，其中含有  com.xbongbong.saas.help.SaasDetailPermissionHelp#checkPermission(com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt, com.xbongbong.paas.toolbox.wrap.UserVO, java.util.Set, java.lang.Integer)
     * @param formEntity
     * @param paasFormDataEntityExt
     * @param loginUser
     * @param subBusinessType
     * @throws XbbException
     */
    void checkPermission(T formEntity, D paasFormDataEntityExt, UserVO loginUser, Integer subBusinessType) throws XbbException;

    /**
     * 获取字段解释
     * @param form
     * @param corpid
     * @return java.util.List<com.xbongbong.paas.field.FieldAttrEntity>
     * @author 吴峰
     * @date 2022/2/12 15:02
     * @throws XbbException
     */
    List<FieldAttrEntity> getExplainList(T form, String corpid) throws XbbException;

    /**
     * 获取解释
     * @param explainList
     * @param handlerExplainDTO
     * @param paasFormDataEntityExt
     * @param formEntity
     * @return
     * @throws XbbException
     */
    HandlerExplainVO handleExplain(List<FieldAttrEntity> explainList, T formEntity, D paasFormDataEntityExt, HandlerExplainDTO handlerExplainDTO) throws XbbException;

    /**
     * 解析数据
     * @param formData
     * @param handlerExplainDTO
     * @param handlerExplainVO
     * @return
     * @throws XbbException
     */
    JSONObject analysisData(D formData,  HandlerExplainDTO handlerExplainDTO, HandlerExplainVO handlerExplainVO) throws XbbException;

    /**
     * 千分位换算
     * @param data
     * @param explainList
     * @param analysisAmountOfThousandBitsWithOriginalValue
     * @throws XbbException
     */
    void analysisGetOfThousandBits(JSONObject data,List<FieldAttrEntity> explainList,Boolean analysisAmountOfThousandBitsWithOriginalValue) throws XbbException;

}
